<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title th:text="${goodsDetail.goodsName}">商品页面</title>

    <link href="assets/css/admin.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/amazeui.css" rel="stylesheet" type="text/css"/>
    <link href="basic/css/demo.css" rel="stylesheet" type="text/css"/>
    <link type="text/css" href="css/optstyle.css" rel="stylesheet"/>
    <link type="text/css" href="css/style.css" rel="stylesheet"/>
    <link type="text/css" href="js/sweetalert/sweetalert.css" rel="stylesheet"/>

    <script type="text/javascript" src="basic/js/jquery-1.7.min.js"></script>
    <script type="text/javascript" src="basic/js/quick_links.js"></script>

    <script type="text/javascript" src="assets/js/amazeui.js"></script>
    <script type="text/javascript" src="js/jquery.imagezoom.min.js"></script>
    <script type="text/javascript" src="js/jquery.flexslider.js"></script>
    <script type="text/javascript" src="js/list.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/sweetalert/sweetalert.min.js"></script>

</head>

<body>
<header th:replace="mall/header::header-user"></header>
<nav th:replace="mall/header::header-search"></nav>
<div class="clear"></div>
<b class="line"></b>
<div class="listMain">

    <ol class="am-breadcrumb am-breadcrumb-slash">
        <li><a href="/">首页</a></li>
    </ol>
    <div class="scoll">
        <section class="slider">
            <div class="flexslider">
                <ul class="slides">
                    <li>
                        <img th:src="@{${goodsDetail.goodsCoverImg}}" title="主图"/>
                    </li>
                </ul>
            </div>
        </section>
    </div>

    <!--放大镜-->
    <div class="item-inform">
        <div class="clearfixLeft" id="clearcontent">
            <div class="box">
                <!-- 大图-->
                <div class="tb-booth tb-pic tb-s310">
                    <a href="images/01.jpg">
                        <img th:src="@{${goodsDetail.goodsCoverImg}}" alt="商品图"
                             th:attr="rel=@{${goodsDetail.goodsCoverImg}}"
                             class="jqzoom"/>
                    </a>
                </div>
                <!-- 小图 -->
                <ul class="tb-thumb" id="thumblist">
                    <li class="tb-selected">
                        <div class="tb-pic tb-s40">
                            <a href="#">
                                <img th:src="@{${goodsDetail.goodsCoverImg}}"
                                     th:attr="mid=@{${goodsDetail.goodsCoverImg}},big=@{${goodsDetail.goodsCoverImg}} "/>
                            </a>
                        </div>
                    </li>
                </ul>
            </div>

            <div class="clear"></div>
        </div>

        <div class="clearfixRight">

            <!--规格属性-->
            <!--名称-->
            <div class="tb-detail-hd">
                <h1 th:text="${goodsDetail.goodsName}">
                    良品铺子 手剥松子218g 坚果炒货 巴西松子
                </h1>
                <h3 th:text="${goodsDetail.goodsIntro}">巴西松子</h3>
            </div>
            <div class="tb-detail-list">
                <!--价格-->
                <div class="tb-detail-price">
                    <li class="price iteminfo_price">
                        <dt>促销价</dt>
                        <dd><em>¥</em><b class="sys_item_price" th:text="${goodsDetail.sellingPrice}">56.90</b></dd>
                    </li>
                    <li class="price iteminfo_mktprice">
                        <dt>原价</dt>
                        <dd><em>¥</em><b class="sys_item_mktprice" th:text="${goodsDetail.originalPrice}">98.00</b></dd>
                    </li>
                    <div class="clear"></div>
                </div>

                <div class="clear"></div>

                <!--销量
                <ul class="tm-ind-panel">
                    <li class="tm-ind-item tm-ind-sellCount canClick">
                        <div class="tm-indcon"><span class="tm-label">月销量</span><span class="tm-count">1015</span></div>
                    </li>
                    <li class="tm-ind-item tm-ind-sumCount canClick">
                        <div class="tm-indcon"><span class="tm-label">累计销量</span><span class="tm-count">6015</span>
                        </div>
                    </li>
                    <li class="tm-ind-item tm-ind-reviewCount canClick tm-line3">
                        <div class="tm-indcon"><span class="tm-label">累计评价</span><span class="tm-count">640</span></div>
                    </li>
                </ul>-->
                <div class="clear"></div>

                <!--各种规格-->
                <dl class="iteminfo_parameter sys_item_specpara">
                    <dt class="theme-login">
                        <div class="cart-title">可选规格<span class="am-icon-angle-right"></span></div>
                    </dt>
                    <dd>
                        <!--操作页面-->

                        <div class="theme-popover-mask"></div>

                        <div class="theme-popover">
                            <div class="theme-span"></div>
                            <div class="theme-poptit">
                                <a href="javascript:;" title="关闭" class="close">×</a>
                            </div>
                            <div class="theme-popbod dform">
                                <form class="theme-signin" name="loginform" action="" method="post">

                                    <div class="theme-signin-left">
                                        <div class="theme-options">
                                            <div class="cart-title number">数量</div>
                    <dd>
                        <input id="min" class="am-btn am-btn-default" name="" type="button" value="-"/>
                        <input id="text_box" name="" type="text" value="1" style="width:30px;"/>
                        <input id="add" class="am-btn am-btn-default" name="" type="button" value="+"/>
                        <span id="Stock" class="tb-hidden">库存<span class="stock"
                                                                   th:text="${goodsDetail.stockNum}">1000</span>件</span>
                    </dd>

            </div>
            <div class="clear"></div>

            <div class="btn-op">
                <div class="btn am-btn am-btn-warning">确认</div>
                <div class="btn close am-btn am-btn-warning">取消</div>
            </div>
        </div>
        <div class="theme-signin-right">
            <div class="img-info">
                <img src="images/songzi.jpg"/>
            </div>
            <div class="text-info">
                <span class="J_Price price-now">¥39.00</span>
                <span id="Stock" class="tb-hidden">库存<span class="stock">1000</span>件</span>
            </div>
        </div>

        </form>
    </div>
</div>

</dd>
</dl>
<div class="clear"></div>
<!--活动	-->
<div class="shopPromotion gold">
    <div class="hot">
        <dt class="tb-metatit">店铺优惠</dt>
        <div class="gold-list">
            <p>优惠中...
            </p>
        </div>
    </div>
    <div class="clear"></div>
</div>
</div>

<div class="pay">
    <li>
        <div class="clearfix tb-btn tb-btn-buy theme-login">
            <a id="LikBuy" title="点此按钮到下一步确认购买信息"
               th:href="'javascript:saveAndGoCart('+${goodsDetail.goodsId}+');'">立即购买</a>
        </div>
    </li>
    <li>
        <div class="clearfix tb-btn tb-btn-basket theme-login">
            <a id="LikBasket" title="加入购物车" th:href="'javascript:saveToCart('+${goodsDetail.goodsId}+');'"><i></i>加入购物车</a>
        </div>
    </li>
</div>

</div>

<div class="clear"></div>

</div>

<!-- 下半页 -->
<div class="introduce">
    <!-- 热门推荐 - ajax加载-->
    <div class="browse">
        <div class="mc">
            <ul>
                <div class="mt">
                    <h2>热门推荐</h2>
                </div>

                <li>
                    <div class="p-img">
                        <a href="#"> <img class="" src="images/browse1.jpg"> </a>
                    </div>
                    <div class="p-name"><a href="#">
                        这个推荐位留着吧
                    </a>
                    </div>
                    <div class="p-price"><strong>￥35.90</strong></div>
                </li>
            </ul>
        </div>
    </div>
    <div class="introduceMain">
        <div class="am-tabs" data-am-tabs>
            <ul class="am-avg-sm-3 am-tabs-nav am-nav am-nav-tabs">
                <li class="am-active">
                    <a href="#">
                        <span class="index-needs-dt-txt">宝贝详情</span></a>
                </li>

                <li>
                    <a href="#">

                        <span class="index-needs-dt-txt">猜你喜欢</span></a>
                </li>
            </ul>

            <div class="am-tabs-bd">
                <!-- 详情页 -->
                <div class="am-tab-panel am-fade am-in am-active">
                    这个详情页放点什么东西呢？--异步加载
                    <div class="clear"></div>

                </div>
                <!-- 猜你喜欢 -->
                <div class="am-tab-panel am-fade">
                    <div class="like">
                        <ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
                            这里弄个ajax异步加载
                            <li>
                                <div class="i-pic limit">
                                    <img src="images/imgsearch1.jpg"/>
                                    <p>【良品铺子_开口松子】零食坚果特产炒货
                                        <span>东北红松子奶油味</span></p>
                                    <p class="price fl">
                                        <b>¥</b>
                                        <strong>298.00</strong>
                                    </p>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="clear"></div>

                    <!--分页 -->
                    <ul class="am-pagination am-pagination-right">
                        <li class="am-disabled"><a href="#">&laquo;</a></li>
                        <li class="am-active"><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li><a href="#">&raquo;</a></li>
                    </ul>
                    <div class="clear"></div>

                </div>

            </div>

        </div>

        <div class="clear"></div>

        <div th:replace="mall/footer::footer-fragment"></div>
    </div>

</div>
</div>

</body>
<script type="text/javascript">
	// 提示要登录
    /**
     * 添加到购物车
     */
    function saveToCart(id) {
        var goodsCount = 1;
        var data = {
            "goodsId": id,
            "goodsCount": goodsCount
        };
        $.ajax({
            type: 'POST',
            url: '/shop-cart',
            contentType: 'application/json',
            data: JSON.stringify(data),
            success: function (result) {
                if (result.resultCode == 200) {
                    swal({
                        title: "添加成功",
                        text: "确认框",
                        icon: "success",
                        buttons: true,
                        dangerMode: true,
                    }).then((flag) => {
                            window.location.reload();
                        }
                    );
                } else {
                    swal(result.message, {
                        icon: "error",
                    });
                }
            },
            error: function () {
                swal("操作失败", {
                    icon: "error",
                });
            }
        });
    }

    /**
     * 添加到购物车并跳转至购物车页面
     */
    function saveAndGoCart(id) {
        // 简单判断登录
        sessionStorage.getItem("userId");

        var goodsCount = 1;
        var data = {
            "goodsId": id,
            "goodsCount": goodsCount
        };
        $.ajax({
            type: 'POST',
            url: '/shop-cart',
            contentType: 'application/json',
            data: JSON.stringify(data),
            success: function (result) {
                if (result.resultCode == 200) {
                    swal({
                        title: "已将商品加入购物车",
                        icon: "success",
                        buttons: {
                            cancel: "留在当前页",
                            confirm: "去购物车结算"
                        },
                        dangerMode: false,
                    }).then((flag) => {
                            if (flag) {
                                window.location.href = '/shop-cart';
                            }
                        }
                    );
                } else {
                    swal(result.message, {
                        icon: "error",
                    });
                }
            },
            error: function () {
                swal("操作失败", {
                    icon: "error",
                });
            }
        });
    }

</script>
<!-- 图片展示 -->
<script type="text/javascript">
$(function() {});
$(window).load(function() {
	$('.flexslider').flexslider({
		animation: "slide",
		start: function(slider) {
			$('body').removeClass('loading');
		}
	});
});

</script>
<script type="text/javascript">
$(document).ready(function() {
	$(".jqzoom").imagezoom();
	$("#thumblist li a").click(function() {
		$(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
		$(".jqzoom").attr('src', $(this).find("img").attr("mid"));
		$(".jqzoom").attr('rel', $(this).find("img").attr("big"));
	});
});

</script>
</html>